// @ts-nocheck
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
const routes = [
  {
    name: 'notFound',
    path: '/:path(.*)+',
    redirect: {
      name: 'search'
    }
  },
  
  {
    name: 'search',
    path: '/mobile/search',
    component: () => import('@/view/search/index.vue'),
    meta: {
      title: '玻璃权益卡'
    }
  },
  {
    name: 'carInfo',
    path: '/mobile/carInfo',
    component: () => import('@/view/carInfo/index.vue'),
    meta: {
      title: '玻璃图片上传系统'
    }
  },
  {
    name: 'resultInfo',
    path: '/mobile/resultInfo',
    component: () => import('@/view/resultInfo/index.vue'),
    meta: {
      title: '玻璃报修'
    }
  },
  {
    name: 'read',
    path: '/mobile/read',
    component: () => import('@/view/read/index.vue'),
    meta: {
      title: '隐私协议'
    }
  }
]

const router = createRouter({
  routes,
  history: createWebHistory()
})

router.beforeEach((to, from, next) => {
  const title = to?.meta?.title
  if (title) {
    document.title = title as string
  }
  next()
})

export default router
